#include "MarsPrecompile.h"

#include "MarsShaderParameter.h"

using namespace Graphics;
using namespace Core;

static const char* PARAMETER_NAME_MAPPINGS[] = 
{
	"worldMatrix",
	"viewMatrix",
	"projMatrix",
	"worldViewProjMatrix",
	"worldInvTransposeMatrix",
	"shadowTransform",
	"eyePosW",
	"directionalLight",
	"material"
};

static Core::uint32 PARAMETER_NAME_HASH_MAPPINGS[] = 
{
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0
};

static bool s_bInit = false;

static void InitParameterNameHashMappings()
{
	Core::uint32 iSize = sizeof( PARAMETER_NAME_MAPPINGS ) / sizeof( const char* );

	for ( Core::uint32 i = 0; i < iSize; ++i )
	{
		PARAMETER_NAME_HASH_MAPPINGS[ i ] = StrCRC::CRC( PARAMETER_NAME_MAPPINGS[ i ] );
	}

	s_bInit = true;
}

Core::uint32 ShaderParameter::GetParameterName( ShaderSemantic semantic )
{
	if ( !s_bInit )
	{
		InitParameterNameHashMappings();
	}

	MARS_ASSERT( ( int )semantic >= 0 && ( int )semantic < sizeof( PARAMETER_NAME_HASH_MAPPINGS ) / sizeof( Core::uint32 ) );
	return PARAMETER_NAME_HASH_MAPPINGS[ ( int ) semantic ];
}
